﻿using System;
using Ninject.Core;
using Ninject.Core.Parameters;

namespace TestBat.ServiceLocator
{
    public class DefaultServiceLocator
    {
        static DefaultServiceLocator()
        {
            instance = new DefaultServiceLocator();
        }

        protected DefaultServiceLocator()
        {
            kernel = new StandardKernel();
        }

        public static object Get(Type type)
        {
            return instance.kernel.Get(type);
        }

        public static O Get<O>()
        {
            return instance.kernel.Get<O>();
        }

        public static O Get<O>(IParameterCollection parameter)
        {
            return instance.kernel.Get<O>(parameter);
        }

        public static IKernel Kernel
        {
            set
            {
                instance.kernel = value;
            }
        }

        protected IKernel kernel;

        private static DefaultServiceLocator instance;

    }
}
